package com.ucode.model.hrm.form;

import cn.hutool.core.util.ObjUtil;
import com.ucode.model.hrm.enums.HrmClockType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDate;

@Schema(description = "人力资源管理系统 - 补卡申请Form")
@Data
@EqualsAndHashCode
@ToString(callSuper = true)
public class HrmAttendanceApplyRecordForm {

    /**
     * 用户ID
     */
    @Schema(description = "员工ID", requiredMode = Schema.RequiredMode.AUTO)
    private Long employeeId;

    @Schema(description = "补卡类型：CLOCK_IN(上班)/CLOCK_OUT(下班)", requiredMode = Schema.RequiredMode.REQUIRED, example = "CLOCK_IN")
    @NotBlank(message = "补卡类型不能为空")
    private String clockType;
    /**
     * 补卡时间
     */
    @Schema(description = "补卡时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "补卡时间不能为空")
    private LocalDate workDate;
    /**
     * 原因
     */
    @Schema(description = "补卡原因", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "补卡原因不能为空")
    @Size(max = 256, message = "补卡原因不能超过 256 个字符")
    private String reason;


    @AssertTrue(message = "打卡类型参数范围不正确")
    public boolean isClockTypeIntervalCheck() {
        if(ObjUtil.equals(HrmClockType.CLOCK_IN,clockType) || ObjUtil.equals(HrmClockType.CLOCK_OUT,clockType)){
            return false;
        }
        return true;
    }

}
